<div data-ng-controller="contractIncomeCtrl">
    <div class="table-header clearfix ng-scope">
        <span class="fl lh30 f14">{{contractBaseInfo.contract_code}}</span>
    </div>
    <form class="form-horizontal">
        <div class="form-group mt10">
            <span class="col-sm-2 control-label ml15">账套公司</span>

            <div class="col-sm-5">
                <input select2 ng-model="contractBaseInfo.account_company_id" select2-model="ddl2Customer"
                       ng-disabled="contractBaseInfo.contract_status != 0"
                       config="ddlConfigCompany" class="form-control" type="text"/>
            </div>
        </div>
    </form>

    <div class="mt20 clearfix ng-scope ml25" ng-if="contractBaseInfo.contract_status == 0 && contractBaseInfo.is_cancelled == 0">
        <button class="btn" href="#" ng-click="addIncome()">新增收入</button>

    </div>
    <form name="contractIncomeEdit" id="grid" class="table-wrap mt10 ml25" style="min-height: 200px;">

        <table width="100%">
            <thead>
            <tr>
                <th width="40">序号</th>
                <th>核算收入类别</th>
                <th width="170" class="align-r">金额</th>
                <th width="245" class="align-m">租期</th>
                <th width="108">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="record in incomes" ng-if="record.__type != 'delete'">
                <td height="40"><p ng-bind="$index + 1"></p></td>
                <td class="lh14">
                    <p ng-if="(record.editMode || 0) == 0" ng-bind="record.type_name"></p>

                    <p ng-if="(record.editMode || 0) != 0">
                        <input select2 ng-model="record.revenue_type" select2-model="record.ddl2Category" data="record"
                               config="ddlConfigIncomeCategory" class="form-control" type="text"/>
                    </p>

                </td>
                <td class="align-r">
                    <p ng-if="(record.editMode || 0)  == 0" ng-bind="record.amount|number:2"></p>

                    <p ng-if="(record.editMode || 0)  != 0">
                        <input number ng-model="record.amount" class="form-control align-r" type="text"/>
                    </p>
                </td>
                <td>{{record.beginOn}}
                    <p ng-if="revenueInfo.beginOn" class="align-m">
                        {{revenueInfo.beginOn|strdate:'yyyy-MM-dd'}}至{{revenueInfo.endOn|strdate:'yyyy-MM-dd'}}
                    </p>
                </td>
                <td>
                    <div ng-if="contractBaseInfo.contract_status == 0">
                        <a ng-if="(record.editMode || 0)  == 0" href="javascript:void(0)"
                           title="修改收入信息"
                           ng-click="editIncome(record)">修改</a>
                        <a ng-if="(record.editMode || 0)  == 0" ng-click="delIncome(record)" href="javascript:void(0)"
                           title="删除收入信息">删除</a>

                        <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                           title="保存收入信息"
                           ng-click="contractIncomeEdit.$valid && editIncomeOk(record)">确定</a>
                        <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                           title="取消修改收入信息"
                           ng-click="editIncomeCancel(record, $index)">取消</a>
                    </div>

                </td>
            </tr>
            </tbody>
        </table>
        <div class="no-data" style="display:none"><span>暂无数据</span></div>

    </form>
    <div class="ml25 mt10">
        <span class="pl10">说明：{{contractBaseInfo|signOrBalanceLabel}}(<em class="b">{{contractBaseInfo|signOrBalanceAmount|number:2}}</em>元) = 已确定收入(<em
                class="b">{{incomes|sumIncomeAmount|number:2}}</em>元) + 未确定收入(<em class="b c-red">{{incomes|remainIncomeAmount:contractBaseInfo|number:2}}</em>元)</span>
    </div>

    <div class="form-group" ng-if="contractBaseInfo.contract_status == 0 && contractBaseInfo.is_cancelled == 0">
        <div class="ml25 mt15">
            <button type="button" ng-click="save()" class="btn btn-default"
                    ng-disabled="incomes|saveEnabled"
                    >保存
            </button>
        </div>
    </div>
</div>